<?php

/**
 * BlogPost form.
 *
 * @package    IPLIFE
 * @subpackage form
 * @author     alexey.shapran@gmail.com
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class BlogPostForm extends BaseBlogPostForm
{
	public function configure()
	{
		$this->setWidgets(array(
      'id'                  => new sfWidgetFormInputHidden(),
      'title'               => new sfWidgetFormInputText(),
      'short'               => new sfWidgetFormTextarea(),
      'body'                => new sfWidgetFormTextareaTinyMCE(array('height'=>200, 'width'=>400, 'theme'=>'advanced')),
      'tags'                => new sfWidgetFormTextarea(),
      'user_id'             => new sfWidgetFormInputHidden(),
      'is_allowed_comments' => new sfWidgetFormInputHidden(),
      'updated_at'          => new sfWidgetFormInputHidden(),
  	  '_csrf_token'			=> new sfWidgetFormInputHidden()
		));

		$this->widgetSchema->setLabels(array(
   		'title'		=> 'Название',
   		'short'		=> 'Краткое описание',
   		'body'		=> 'Основное описание',
   		'tags'		=> 'Ключевые слова'
   		));   		
   		
   		$this->validatorSchema = new sfValidatorSchema(array(
   		'id'                  => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
   		'title'				=> new sfValidatorString(array('required'=>true)),
   		'short'				=> new sfValidatorString(array('required'=>true)),
   		'body'				=> new sfValidatorString(array('required'=>true)),
   		'tags'                => new sfValidatorString(array('required' => false)),
     	'user_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUser'), 'required' => false)),
    	'is_allowed_comments' => new sfValidatorInteger(array('required' => false)),
   		'updated_at'          => new sfValidatorDateTime(array('required' => false)),
   		));
   		
   		$this->widgetSchema->setHelps(array(
   		'tags'=>'<div class="helps">(ключевые слова, через запятую, не более 5)</div>',
   		));
   		
   		$this->widgetSchema->setNameFormat('post[%s]');
	}
}
